home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Inventor Labs: Technology
/
INVENTORLABS_TECHNOLOGY.BIN
/
pc
/
files
/
gears.dir
/
00210_Script_Gear Manger Parent
< prev
next >
Wrap
Text File
|
1997-05-26
|
14KB
|
367 lines
--o Gear Mgr parent
-- gGearMgrParent
property pActiveGearList, pGearScript
property pActiveSpeed
property pMaxGears, pCurrNumOfGears
property pNewGearStartSprite, pGearCastLst, pNextAvailGearSprite
property pAvailGearStartSprite, pActiveGearRects, pCurrentDragCast, pDraggingGearSize
property pSnapped, pNeighborHorz, pNeighborVert, pNeighborSize, pDragGearStep
property pRadius, pDistance, pSnapSide, pSliderActive, pCurrTempo
property pLeftSliderEdge, pSliderSprite,pGridContraintSprite, pAjoiningEdge, pHorzStick, pVertStick
property pScreenOnGear, pScreenSprite, pScreenDirection, pScreenFirstCast, pScreenLastCast,pGearInc
property pScreenRefresh, pScreenCurrCast, pDriveGearObj
global gGearMgrParent
------------------------------------------------------------------------------------------------------------
on mInit me
set pGearScript = script "gear parent"
set SmallGearCast = [the number of cast "ISMGR00000", the number of cast "ISMGR00023"]
set MidGearCast = [the number of cast "IGRMD00000", the number of cast "IGRMD00035"]
set LargeGearCast = [the number of cast "IGRLG00000", the number of cast "IGRLG00047"]
set pGearCastLst =[LargeGearCast, MidGearCast, SmallGearCast]
set pRadius = [#small: 25,#Middle:36,#Large:47]
set pGridContraintSprite = 8
set pMaxGears = 8
set pCurrNumOfGears = 0
set pAvailGearStartSprite = 9
set pNextAvailGearSprite = pAvailGearStartSprite
set pNewGearStartSprite = 5
set pSnapped = FALSE
set pActiveGearList = []
set pActiveGearRects = []
set pSliderActive = FALSE
set pSliderSprite = 22
set pCurrTempo = 10
set pScreenOnGear = FALSE
set pScreenSprite = 19
set pScreenDirection = 0
set pScreenFirstCast = the number of cast "gearmv00000"
set pScreenLastCast = the number of cast "gearmv00060"
set pGearInc = 0
set pScreenRefresh = 0
set pScreenCurrCast = pScreenFirstCast
return( me )
end mInit
------------------------------------------------------------------------------------------------------------
on mActivate me
puppettempo pCurrTempo
set pCurrNumOfGears = 1
set whatcast = [the number of cast "IGRDW00000", the number of cast "IGRDW00023"]
set pDriveGearObj = birth( pGearScript,#small,whatcast,pNextAvailGearSprite,1,the number of cast "IGRDW00000",4,0)
set pActiveGearList = [pDriveGearObj]
set pNextAvailGearSprite = pNextAvailGearSprite + 1
set pLeftSliderEdge = the left of sprite (pSliderSprite -1)
puppetsprite pSliderSprite, TRUE
puppetsprite pScreenSprite, TRUE
set the constraint of sprite pScreenSprite = pScreenSprite - 1
end mActivate
------------------------------------------------------------------------------------------------------------
on mclose me
repeat with spriteNum = pAvailGearStartSprite to pNextAvailGearSprite
puppetsprite spriteNum, false
set the constraint of sprite spriteNum = 0
end repeat
puppetsprite pSliderSprite, False
puppetsprite pScreenSprite, False
set the constraint of sprite pScreenSprite = 0
end mclose
------------------------------------------------------------------------------------------------------------
on mSetSpeed me
set pSliderActive = TRUE
when mouseup then mReleaseSlider( gGearMgrParent )
end mSetSpeed
------------------------------------------------------------------------------------------------------------
on mReleaseSlider me
when mouseup then
set pSliderActive = FALSE
end mReleaseSlider
------------------------------------------------------------------------------------------------------------
on mPerform me
if (pCurrTempo >= 7) then
repeat with gear in pActiveGearList
mPerform( gear )
end repeat
end if
if pSliderActive then
set newh = the mouseh
if newh > 600 then set newh = 600
else if newh < 512 then set newh = 512
set the loch of sprite pSliderSprite = newh
set pCurrTempo = integer((the loch of sprite pSliderSprite - pLeftSliderEdge) * .5) + 5
if pCurrTempo > 45 then set pCurrTempo = 120
puppettempo pCurrTempo
end if
if pcurrTempo <= 6 then set pActiveSpeed = 0
else set pActiveSpeed = 1
if pScreenOnGear and pActiveSpeed then
set pScreenRefresh = pScreenRefresh + 1
if (pScreenRefresh mod pGearInc) = 0 then
set newcast = pScreenCurrCast + 1* pScreenDirection
if newcast > pScreenLastCast then set newcast = pScreenFirstCast
else if newcast < pScreenFirstCast then set newcast = pScreenLastCast
set pScreenCurrCast = newcast
set the castnum of sprite pScreenSprite = pScreenCurrCast
end if
end if
go the frame
end mPerform
------------------------------------------------------------------------------------------------------------
on mNewGear me
if (pCurrNumOfGears < pMaxGears) then
set whatGearCast = getat(pGearCastLst, (the clickon - pNewGearStartSprite) + 1)
birth( pGearScript, whatGearCast,pNextAvailGearSprite,0)
set pNextAvailGearSprite = pNextAvailGearSprite + 1
set pCurrNumOfGears = pCurrNumOfGears + 1
end if
end mNewGear
------------------------------------------------------------------------------------------------------------
on mDragGear me
if (pCurrNumOfGears < pMaxGears) then
set pDragginGear = (the clickon - pNewGearStartSprite) + 1 -- 1 is large, 2, is medium
set CastRange = getat(pGearCastLst, pDragginGear)
set pCurrentDragCast = getat(CastRange , 1) -- return first cast in Cycle for that gear
set the castnum of sprite pNextAvailGearSprite = pCurrentDragCast
set pDragGearStep = 0
set pDraggingGearSize = getat([#Large,#Middle,#small],pDragginGear)
set pSnapped = FALSE
repeat while the mousedown
set MouseH = the mouseh
set MouseV = the mousev
set MousePnt = point(MouseH, MouseV)
if rollover(pGridContraintSprite) then set the constraint of sprite pNextAvailGearSprite to pGridContraintSprite
set SpriteToCheck = pAvailGearStartSprite
set found = FALSE
repeat while (not found) and (SpriteToCheck < pNextAvailGearSprite ) and not pSnapped
if sprite pNextAvailGearSprite intersects SpriteToCheck then
set NeighborGearObj = getat(pActiveGearList,(SpriteToCheck - pAvailGearStartSprite + 1))
mSnapNeighbor( me, mGetNeighborCords(NeighborGearObj), MouseH, MouseV)
set found = TRUE
else set SpriteToCheck = SpriteToCheck + 1
end repeat
if pSnapped then
if abs(pNeighborHorz - MouseH) > pHorzStick then
set the loch of sprite pNextAvailGearSprite = MouseH
set pSnapped = FALSE
else if abs(pNeighborVert - MouseV) > pVertStick then
set the locv of sprite pNextAvailGearSprite = MouseV
set pSnapped = FALSE
end if
else if not found then
set the loch of sprite pNextAvailGearSprite = MouseH
set the locv of sprite pNextAvailGearSprite = MouseV
end if
updatestage
end repeat -- Mousedown
if pSnapped then
set direction = -1 * mGetDirection( NeighborGearObj )
set NewGear = birth( pGearScript,pDraggingGearSize,CastRange,pNextAvailGearSprite,¼
direction,pCurrentDragCast, pAjoiningEdge,NeighborGearObj)
set pCurrNumOfGears = pCurrNumOfGears + 1
append( pActiveGearList,NewGear)
set pNextAvailGearSprite = pNextAvailGearSprite + 1
mSetNeighbor( NeighborGearObj, pSnapSide, NewGear)
else set the constraint of sprite pNextAvailGearSprite to 0
mMoveScreen (me, TRUE)
end if
end mDragGear
------------------------------------------------------------------------------------------------------------
on mReset me
repeat with spritenum = (pAvailGearStartSprite + 1) to pNextAvailGearSprite
puppetsprite spritenum, false
set the constraint of sprite spritenum = 0
end repeat
set pActiveGearList = [pDriveGearObj]
set pNextAvailGearSprite = pAvailGearStartSprite + 1
set pSnapped = FALSE
set pCurrNumOfGears = 1
set pScreenOnGear = FALSE
mClearAllNeighbor ( pDriveGearObj )
mSetNeighbor ( pDriveGearObj , 3)
set the rect of sprite pScreenSprite = rect(397, 44, 545, 162)
end mReset
------------------------------------------------------------------------------------------------------------
on mRemoveGear me
if the doubleclick and (the clickon = pNextAvailGearSprite - 1) then
set the castnum of sprite (pNextAvailGearSprite - 1) = 0
set whatgear = getat(pActiveGearList, count(pActiveGearList))
mInformNeighbors( whatgear )
deleteat(pActiveGearList, count(pActiveGearList))
puppetsprite (pNextAvailGearSprite - 1), FALSE
set pNextAvailGearSprite = pNextAvailGearSprite -1
set the constraint of sprite pNextAvailGearSprite = 0
set pCurrNumOfGears = pCurrNumOfGears - 1
mMoveScreen (me, TRUE)
end if
end mRemoveGear
------------------------------------------------------------------------------------------------------------
on mSnapNeighbor me, GearInfo, MouseH, MouseV
set pNeighborHorz = getat( GearInfo, 1)
set pNeighborVert = getat( GearInfo, 2)
set pNeighborSize = getat( GearInfo, 3)
set pNeighborStep = getat( GearInfo, 4)
set pNeighborAvialSlots = getat( GearInfo, 5)
---- rotate to align teeth
if (pDragGearStep = pNeighborStep) or (pDragGearStep + pNeighborStep = 3) then
set pDragGearStep = (pDragGearStep + 1) mod 3
set pCurrentDragCast = pCurrentDragCast + 1
set the castnum of sprite pNextAvailGearSprite = pCurrentDragCast
end if
----
set pDistance = (getprop(pRadius,pNeighborSize) + getprop(pRadius,pDraggingGearSize))
set snapDistance = pDistance - 4
if abs( MouseH - pNeighborHorz) >= abs( MouseV - pNeighborVert) then
if (MouseH <= pNeighborHorz) and (getat(pNeighborAvialSlots,1) = 1) then
set the loch of sprite pNextAvailGearSprite = (pNeighborHorz - snapDistance)
set the locv of sprite pNextAvailGearSprite = pNeighborVert
set pSnapSide = 1
else if (MouseH > pNeighborHorz) and (getat(pNeighborAvialSlots,3) = 1) then
set the loch of sprite pNextAvailGearSprite = (pNeighborHorz + snapDistance)
set the locv of sprite pNextAvailGearSprite = pNeighborVert
set pSnapSide = 3
end if
set pHorzStick = pDistance
set pVertStick = pDistance --getprop(pRadius,pDraggingGearSize)/4
else
if (MouseV <= pNeighborVert) and (getat(pNeighborAvialSlots,2) = 1) then
set the locV of sprite pNextAvailGearSprite = (pNeighborVert - snapDistance)
set the locH of sprite pNextAvailGearSprite = pNeighborHorz
set pSnapSide = 2
else if (MouseV > pNeighborVert) and (getat(pNeighborAvialSlots,4) = 1) then
set the locV of sprite pNextAvailGearSprite = (pNeighborVert + snapDistance)
set the locH of sprite pNextAvailGearSprite = pNeighborHorz
set pSnapSide = 4
end if
set pHorzStick = pDistance --getprop(pRadius,pDraggingGearSize)/4
set pVertStick = pDistance
end if
set pAjoiningEdge = (pSnapSide + 2) Mod 5
if pAjoiningEdge = 0 then set pAjoiningEdge = 1
set pSnapped = TRUE
updatestage
end mSnapNeighbor
------------------------------------------------------------------------------------------------------------
on mMoveScreen me, GearPlaced
if not GearPlaced then
set Hoffset = abs((the loch of sprite pScreenSprite) - the mouseH)
set Voffset = abs((the locv of sprite pScreenSprite) - the mouseV)
end if
repeat while the mousedown or GearPlaced
if GearPlaced then set GearPlaced = FALSE
else
set the loch of sprite pScreenSprite = (the mouseH - Hoffset)
set the locv of sprite pScreenSprite = (the mouseV - Voffset )
updatestage
end if
set SpriteToCheck = pAvailGearStartSprite
set found = FALSE
repeat while (not found) and (SpriteToCheck < pNextAvailGearSprite )
if sprite pScreenSprite intersects SpriteToCheck then
set NeighborGearObj = getat(pActiveGearList,(SpriteToCheck - pAvailGearStartSprite + 1))
set gearInfo = mGetNeighborCords(NeighborGearObj)
set pNeighborSize = getat( GearInfo, 3)
set pNeighborVert = getat( GearInfo, 2)
set NeighborRadius = getprop(pRadius,pNeighborSize)
set maxlocv = pNeighborVert + NeighborRadius
if the locv of sprite pScreenSprite > maxlocv then
set the locv of sprite pScreenSprite = maxlocv
updatestage
end if
set pGearInc = getprop([#small:1,#middle:2,#Large:3],pNeighborSize)
set pScreenRefresh = 0
set pScreenDirection = mGetDirection( NeighborGearObj )
set pScreenOnGear = TRUE
set Found = TRUE
else
set SpriteToCheck = SpriteToCheck + 1
set pScreenOnGear = FALSE
end if
end repeat
end repeat
end mMoveScreen
------------------------------------------------------------------------------------------------------------